package cn.darkhorse.common.util;

import java.util.Base64;

public class Base64Util {

        /***
         * BASE64解密
         * @param key
         * @return
         * @throws Exception
         */
        public static byte[] decryBASE64(String key) throws Exception{
            Base64.Decoder decoder = Base64.getDecoder();
            byte[] buffer = decoder.decode(key);
            return buffer;
        }

        /***
         * BASE64加密
         * @param key
         * @return
         * @throws Exception
         */
        public static String encryptBASE64(byte[] key) throws Exception{
            Base64.Encoder encoder = Base64.getEncoder();
            byte[] buffer = encoder.encode(key);
            return new String(buffer,"UTF-8");
        }

}
